from django.shortcuts import render_to_response, get_object_or_404
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from djangopledgedrive.pledgedrives.models import PledgedriveDrive
from djangopledgedrive.pledgedrives.models import PledgedriveStation
from django.template import Context, loader

def detail(request, pledgedrive_id):
    # return HttpResponse("You're looking at pledge drive %s." % pledgedrive_id)

    pledgedrives_list = PledgedriveDrive.objects.all() #[pledgedrive_id]
    t = loader.get_template('pledgedrives/detail.html')	
    c = Context({
		'pledgedrives_list': pledgedrives_list,
    })

    return HttpResponse(t.render(c))


def index(request):
	# latest_pledgedrives_list = PledgedriveDrive.objects.all().order_by('-id')[:5]
    pledgedrives_list = PledgedriveDrive.objects.all()
	
	# this is returns an unstyled comma delimited list...
	# output = ', '.join([p.question for p in latest_pledgedrives_list])
	# return HttpResponse(output)

    t = loader.get_template('pledgedrives/index.html')
	
    c = Context({
		'pledgedrives_list': pledgedrives_list,
    })

    return HttpResponse(t.render(c))
